﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DrugStore.FormCollect;

namespace DrugStore.FormCollect
{
    public partial class MainFormAdmin : Form
    {
        private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        private static DanhMucNhaCungCap fr_NhaCungCap;
        private static DanhMucNhaSanXuat fr_NhaSanXuat;
        private static DanhMucNhomHangHoa fr_NhomHangHoa;
        private static DanhMucDonViHangHoa fr_NhomDonViHangHoa;
        private static Xuat_BanTheoToaKhach fr_BanTheoToaKhach;
        private static Xuat_BanTheoToaPhongKham fr_BanTheoToaPhongKham;
        private static Xuat_BanTheoYeuCauKhach fr_BanTheoYeuCauKhach;
        private static Xuat_Huy fr_XuatHuy;
        private static NhapHang fr_NhapHang;
        private static BaoCaoDoanhSo fr_BaoCaoDoanhSo;
        private static BaoCaoTonKho fr_BaoCaoTonKho;
        private static GioiThieu fr_GioiThieu;
        private static HuongDanSuDung fr_HuongDanSuDung;
        private static QuanLyNguoiSuDung fr_QuanLyNguoiSuDung;
        private static TaoToaThuocMau fr_TaoToaThuocMau;
 

        public MainFormAdmin()
        {
            InitializeComponent();
        }

        public void DestroyChild(string FormName)
        {
            if (fr_NhaCungCap != null && FormName == fr_NhaCungCap.Name.ToString())
                fr_NhaCungCap = null;
            else if (fr_NhaSanXuat != null && FormName == fr_NhaSanXuat.Name.ToString())
                fr_NhaSanXuat = null;
            else if (fr_NhomHangHoa != null && FormName == fr_NhomHangHoa.Name.ToString())
                fr_NhomHangHoa = null;
            else if (fr_NhomDonViHangHoa != null && FormName == fr_NhomDonViHangHoa.Name.ToString())
                fr_NhomDonViHangHoa = null;
            else if (fr_BanTheoToaKhach != null && FormName == fr_BanTheoToaKhach.Name.ToString())
                fr_BanTheoToaKhach = null;
            else if (fr_BanTheoToaPhongKham != null && FormName == fr_BanTheoToaPhongKham.Name.ToString())
                fr_BanTheoToaPhongKham = null;
            else if (fr_BanTheoYeuCauKhach != null && FormName == fr_BanTheoYeuCauKhach.Name.ToString())
                fr_BanTheoYeuCauKhach = null;
            else if (fr_XuatHuy != null && FormName == fr_XuatHuy.Name.ToString())
                fr_XuatHuy = null;
            else if (fr_NhapHang != null && FormName == fr_NhapHang.Name.ToString())
                fr_NhapHang = null;
            else if (fr_BaoCaoDoanhSo != null && FormName == fr_BaoCaoDoanhSo.Name.ToString())
                fr_BaoCaoDoanhSo = null;
            else if (fr_BaoCaoTonKho != null && FormName == fr_BaoCaoTonKho.Name.ToString())
                fr_BaoCaoTonKho = null;
            else if (fr_GioiThieu != null && FormName == fr_GioiThieu.Name.ToString())
                fr_GioiThieu = null;
            else if (fr_HuongDanSuDung != null && FormName == fr_HuongDanSuDung.Name.ToString())
                fr_HuongDanSuDung = null;
            else if (fr_QuanLyNguoiSuDung != null && FormName == fr_QuanLyNguoiSuDung.Name.ToString())
                fr_QuanLyNguoiSuDung = null;
            else if (fr_TaoToaThuocMau != null && FormName == fr_TaoToaThuocMau.Name.ToString())
                fr_TaoToaThuocMau = null;
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            log.Fatal("MainAdmin");
        }

        private void hàngHóaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_NhomHangHoa == null)
            {
                fr_NhomHangHoa = new DanhMucNhomHangHoa();
                fr_NhomHangHoa.MdiParent = this;
                fr_NhomHangHoa.Show();
            }
            //fr_NhomHangHoa.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_NhomHangHoa.Show();
        }
                
        private void nhàCungCấpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_NhaCungCap == null)
            {
                fr_NhaCungCap = new DanhMucNhaCungCap();
                fr_NhaCungCap.MdiParent = this;
                fr_NhaCungCap.Show();
            }
            //fr_NhaCungCap.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_NhaCungCap.Show();
        }

        private void nhàSảnXuấtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_NhaSanXuat == null)
            {
                fr_NhaSanXuat = new DanhMucNhaSanXuat();
                fr_NhaSanXuat.MdiParent = this;
                fr_NhaSanXuat.Show();
            }
            //fr_NhaSanXuat.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_NhaSanXuat.Show();
        }

        private void đơnVịHàngHóaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_NhomDonViHangHoa == null)
            {
                fr_NhomDonViHangHoa = new DanhMucDonViHangHoa();
                fr_NhomDonViHangHoa.MdiParent = this;
                fr_NhomDonViHangHoa.Show();
            }
           //fr_NhomDonViHangHoa.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_NhomDonViHangHoa.Show();
        }

        private void bánTheoToaPhòngKhámToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_BanTheoToaPhongKham == null)
            {
                fr_BanTheoToaPhongKham = new Xuat_BanTheoToaPhongKham();
                fr_BanTheoToaPhongKham.MdiParent = this;
                fr_BanTheoToaPhongKham.Show();
            }
            //fr_BanTheoToaPhongKham.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_BanTheoToaPhongKham.Show();
        }

        private void bánTheoToaNgườiMuaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_BanTheoToaKhach == null)
            {
                fr_BanTheoToaKhach = new Xuat_BanTheoToaKhach();
                fr_BanTheoToaKhach.MdiParent = this;
                fr_BanTheoToaKhach.Show();
            }
            //fr_BanTheoToaKhach.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_BanTheoToaKhach.Show();
        }

        private void bánTheoYêuCầuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_BanTheoYeuCauKhach == null)
            {
                fr_BanTheoYeuCauKhach = new Xuat_BanTheoYeuCauKhach();
                fr_BanTheoYeuCauKhach.MdiParent = this;
                fr_BanTheoYeuCauKhach.Show();
            }
            //fr_XuatHuy.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_BanTheoYeuCauKhach.Show();
        }

        private void nhậpHàngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_NhapHang == null)
            {
                fr_NhapHang = new NhapHang();
                fr_NhapHang.MdiParent = this;
                fr_NhapHang.Show();
            }
            //fr_NhapHang.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_NhapHang.Show();
        }

        private void doanhThuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_BaoCaoDoanhSo == null)
            {
                fr_BaoCaoDoanhSo = new BaoCaoDoanhSo();
                fr_BaoCaoDoanhSo.MdiParent = this;
                fr_BaoCaoDoanhSo.Show();
            }
            //fr_BaoCaoDoanhSo.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_BaoCaoDoanhSo.Show();
        }

        private void tồnKhoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_BaoCaoTonKho == null)
            {
                fr_BaoCaoTonKho = new BaoCaoTonKho();
                fr_BaoCaoTonKho.MdiParent = this;
                fr_BaoCaoTonKho.Show();
            }
           // fr_BaoCaoTonKho.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_BaoCaoTonKho.Show();
        }

        private void giớiThiệuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_GioiThieu == null)
            {
                fr_GioiThieu = new GioiThieu();
                fr_GioiThieu.MdiParent = this;
                fr_GioiThieu.Show();
            }
            //fr_GioiThieu.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_GioiThieu.Show();
        }

        private void hướngDẫnSửDụngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_HuongDanSuDung == null)
            {
                fr_HuongDanSuDung = new HuongDanSuDung();
                fr_HuongDanSuDung.MdiParent = this;
                fr_HuongDanSuDung.Show();
            }
            //fr_HuongDanSuDung.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_HuongDanSuDung.Show();
        }

        private void ngườiDùngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_QuanLyNguoiSuDung == null)
            {
                fr_QuanLyNguoiSuDung = new QuanLyNguoiSuDung();
                fr_QuanLyNguoiSuDung.MdiParent = this;
                fr_QuanLyNguoiSuDung.Show();
            }
            //fr_QuanLyNguoiSuDung.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_QuanLyNguoiSuDung.Show();
        }

        private void nhậpHàngToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (fr_NhapHang == null)
            {
                fr_NhapHang = new NhapHang();
                fr_NhapHang.MdiParent = this;
                fr_NhapHang.Show();
            }
            //fr_NhapHang.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_NhapHang.Show();
        }

        private void thoátToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void tạoToaThuốcMẫuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fr_TaoToaThuocMau == null)
            {
                fr_TaoToaThuocMau = new TaoToaThuocMau();
                fr_TaoToaThuocMau.MdiParent = this;
                fr_TaoToaThuocMau.Show();
            }
            //fr_TaoToaThuocMau.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_TaoToaThuocMau.Show();
        }

        private void kiểu1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade);
        }

        private void kiểu2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(System.Windows.Forms.MdiLayout.ArrangeIcons);
        }

        private void kiểu3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(System.Windows.Forms.MdiLayout.TileHorizontal);
        }

        private void kiểu4ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(System.Windows.Forms.MdiLayout.TileVertical);
        }

        private void MainFormAdmin_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Confirm user wants to close
            switch (MessageBox.Show(this, "Bạn có chắc đã hoàn thành xong công việc?", "Thoát chương trình", MessageBoxButtons.YesNo))
            {
                case DialogResult.No:
                    e.Cancel = true;
                    break;
                default:
                    break;
            }        
        }

        private void bindingSource1_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void kếtNốiDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

        private void tấtCảThuốcVàVậtTưYTếToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /*
            if (fr_HangHoa == null)
            {
                fr_HangHoa = new TaoToaThuocMau();
                fr_HangHoa.MdiParent = this;
                fr_HangHoa.Show();
            }
            //fr_HangHoa.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_HangHoa.Show();
            */

        }

        private void tạoToaThuốcMẫuToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (fr_TaoToaThuocMau == null)
            {
                fr_TaoToaThuocMau = new TaoToaThuocMau();
                fr_TaoToaThuocMau.MdiParent = this;
                fr_TaoToaThuocMau.Show();
            }
            //fr_TaoToaThuocMau.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            fr_TaoToaThuocMau.Show();
        }

        private void đơnVịTínhToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void càiĐặtToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
    }
}
